package com.ftg.learn.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ftg.learn.common.result.Result;
import com.ftg.learn.order.entity.OrderDetail;
import com.ftg.learn.order.mapper.OrderDetailMapper;
import com.ftg.learn.order.service.OrderDetailService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements OrderDetailService {
    @Override
    public Result<List<OrderDetail>> getOrderDetail(String orderId) {
        LambdaQueryWrapper<OrderDetail> lambdaQuery = Wrappers.lambdaQuery();
        lambdaQuery.eq(OrderDetail::getOrderId, orderId);
        List<OrderDetail> orderDetailList = this.baseMapper.selectList(lambdaQuery);
        if(orderDetailList.size() == 0){
            return Result.build(200, "没有订单详情");
        }
        return Result.build(200, "查询成功", orderDetailList);
    }
}
